package com.speily.web.http;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * @Auther: SPL
 * @Date: 2019-07-03 11:09
 * @Description: 自定义Request
 */
public class Request {

    private String method;
    private String url;

    /**
     * 构造函数-解析输入流
     * @return
     */
    public Request(InputStream inputStream) throws IOException {
        //BufferedReader类从字符输入流中读取文本并缓冲字符，以便有效地读取字符，数组和行
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
        String[] params = bufferedReader.readLine().split(" ");
        this.method = params[0];
        this.url = params[1];

        System.out.println("------------请求方法：" + method);
        System.out.println("------------请求路径：" + url);
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }
}
